package genomemap.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * IO assuming paths are absolute file paths under no security constraint (as in a desktop runtime)
 * @author Susanta Tewari 
 */
public class DesktopIO implements PlatformIO {

    /**
     *
     * @param filePath absolute file path in a filesystem
     * @return the output stream or <code>null</code> if not found
     */
    @Override
    public InputStream getInputStream(String filePath) {

        try {
            return new FileInputStream(filePath);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, ex.getMessage());
            return null;
        }

    }

    /**
     *
     * @param filePath absolute file path in a filesystem
     * @return the output stream or <code>null</code> if not found
     */
    @Override
    public OutputStream getOutputStream(String filePath) {
        try {
            return new FileOutputStream(filePath);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, ex.getMessage());
            return null;
        }
    }

}
